﻿using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

namespace K9Nano.Authorization
{
    public interface IRoleResourceStore
    {
        /// <summary>
        /// 获取角色可以访问的Api资源
        /// </summary>
        /// <returns></returns>
        ValueTask<IReadOnlyList<string>> GetResourcesAsync([NotNull]string api, [NotNull]IEnumerable<string> roles, CancellationToken cancellation);

        /// <summary>
        /// 获取可以访问Api资源的角色
        /// </summary>
        ValueTask<IReadOnlyList<string>> GetRolesInResourceAsync([NotNull]string api, [NotNull]string resource, CancellationToken cancellation);

        /// <summary>
        /// 移除角色与Api资源的绑定
        /// </summary>
        ValueTask RemoveRoleFromResourcesAsync([NotNull]string api, [NotNull]string resource, [NotNull]IEnumerable<string> roles, CancellationToken cancellation);

        /// <summary>
        /// 绑定角色与Api资源
        /// </summary>
        ValueTask AddRoleToResourcesAsync([NotNull]string api, string role, [NotNull]IEnumerable<string> resources, CancellationToken cancellation);
    }
}